package com.zx.mq.work;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消息被Receiver1和Receiver2均匀消费了，实际中可部署多台服务器，作为集群方案
 */
@Component
@RabbitListener(queues = "works")
public class WorkReceiver1 {

    @RabbitHandler
    public void process(String msg) throws InterruptedException {
        System.out.println("Receiver1 doing..."+msg);
        Thread.sleep(1000);
        System.out.println("Receiver1 over: "+msg);
    }
}
